package com.fr.report.io.xml;

import com.fr.base.xml.XMLObject;
import com.fr.base.xml.XMLableReader;
import com.fr.data.impl.ClassTableData;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.DatabaseConnection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.dialog.NameObject;
import com.fr.report.parameter.Parameter;
import java.util.ArrayList;
import java.util.List;

public class ReportDeprecatedXMLUtils
{
  public static NameObject readNamedDatasource_2006_02(XMLableReader paramXMLableReader)
  {
    String str;
    if ((str = paramXMLableReader.getAttr("class")) != null)
    {
      if ((str.endsWith(".NamedJDBCDatasource")) || (str.endsWith(".JDBCNamedDatasource")))
        return readNamedJDBCDatasource_2006_02(paramXMLableReader);
      if (str.endsWith(".ClassNamedDatasource"))
        return readNamedClassDatasource_2006_02(paramXMLableReader);
    }
    return null;
  }

  private static NameObject readNamedJDBCDatasource_2006_02(XMLableReader paramXMLableReader)
  {
    1 local1;
    String str = null;
    DBTableData localDBTableData = new DBTableData();
    paramXMLableReader.readXMLObject(local1 = new XMLObject(null, localDBTableData)
    {
      private final DBTableData val$dbTableData;

      public void readXML(XMLableReader paramXMLableReader)
      {
        if (paramXMLableReader.isChildNode())
        {
          String str2;
          String str1 = paramXMLableReader.getTagName();
          if (str1.equals("Attributes"))
          {
            if ((str2 = paramXMLableReader.getAttr("name")) != null)
              this.obj = str2;
          }
          else
          {
            Object localObject1;
            Object localObject2;
            if ((str1.equals("NamedJDBCDatabase")) || (str1.equals("JDBCNamedDatabase")))
            {
              localObject1 = this.val$dbTableData.getDatabase();
              if (localObject1 == null)
              {
                localObject1 = new JDBCDatabaseConnection();
                this.val$dbTableData.setDatabase((DatabaseConnection)localObject1);
              }
              localObject2 = (JDBCDatabaseConnection)localObject1;
              if ((str2 = paramXMLableReader.getAttr("driver")) != null)
                ((JDBCDatabaseConnection)localObject2).setDriver(str2);
              if ((str2 = paramXMLableReader.getAttr("url")) != null)
                ((JDBCDatabaseConnection)localObject2).setURL(str2);
              if ((str2 = paramXMLableReader.getAttr("user")) != null)
                ((JDBCDatabaseConnection)localObject2).setUser(str2);
              if ((str2 = paramXMLableReader.getAttr("password")) != null)
                ((JDBCDatabaseConnection)localObject2).setPassword(ReportXMLUtils.unPasswordString(str2));
              if ((str2 = paramXMLableReader.getAttr("originalCharsetNamee")) != null)
                ((JDBCDatabaseConnection)localObject2).setOriginalCharsetName(str2);
              if ((str2 = paramXMLableReader.getAttr("newCharsetName")) != null)
                ((JDBCDatabaseConnection)localObject2).setNewCharsetName(str2);
            }
            else if (str1.equals("Query"))
            {
              if ((str2 = paramXMLableReader.getElementValue()) != null)
                this.val$dbTableData.setQuery(str2);
            }
            else if ("Parameters".equals(str1))
            {
              localObject1 = new ArrayList();
              paramXMLableReader.readXMLObject(new ReportDeprecatedXMLUtils.2(this, (List)localObject1));
              if (((List)localObject1).size() > 0)
              {
                localObject2 = new Parameter[((List)localObject1).size()];
                ((List)localObject1).toArray(localObject2);
                this.val$dbTableData.setParameters(localObject2);
              }
            }
          }
        }
      }
    });
    return new NameObject(str = (String)local1.getObject(), localDBTableData);
  }

  private static NameObject readNamedClassDatasource_2006_02(XMLableReader paramXMLableReader)
  {
    3 local3;
    ClassTableData localClassTableData = new ClassTableData();
    paramXMLableReader.readXMLObject(local3 = new XMLObject(null, localClassTableData)
    {
      private final ClassTableData val$classTableData;

      public void readXML(XMLableReader paramXMLableReader)
      {
        if (paramXMLableReader.isChildNode())
        {
          String str1 = paramXMLableReader.getTagName();
          if (str1.equals("Attributes"))
          {
            String str2;
            if ((str2 = paramXMLableReader.getAttr("name")) != null)
              this.obj = str2;
            if ((str2 = paramXMLableReader.getAttr("className")) != null)
              this.val$classTableData.setClassName(str2);
          }
        }
      }
    });
    return new NameObject((String)local3.getObject(), localClassTableData);
  }
}